locals {
  ecs_web      = data.terraform_remote_state.ecs.outputs.ecs_info["ecs_web"]
  ecs_voip     = data.terraform_remote_state.ecs.outputs.ecs_info["ecs_voip"]
  ecs_myapp = data.terraform_remote_state.cce-nodes.outputs.cce_nodes_info["cce-myapp"]

  ecs_web_ips      = values(local.ecs_web)
  ecs_voip_ips     = values(local.ecs_voip)
  ecs_myapp_ips = values(local.ecs_myapp)

  flattened_elb_member = flatten([
    for ip in concat(local.ecs_web_ips, local.ecs_voip_ips, local.ecs_myapp_ips) : [
      {
        elb_key = "elb-web"
        ip      = ip
      }
    ]
  ])

  elb_member_map = {
    for member in local.flattened_elb_member :
    member.ip => member
  }
}


// ELB-SuperHUB-Web-Dev
resource "huaweicloud_lb_loadbalancer" "elb-superhub-web-dev" {
  name          = "elb-superhub-web-dev"
  vip_subnet_id = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-web.ipv4_subnet_id
}

resource "huaweicloud_vpc_eip_associate" "elb-eipassociate-web-dev" {
  public_ip = data.terraform_remote_state.eip.outputs.eip_info["eip_elb_web"].address
  port_id   = huaweicloud_lb_loadbalancer.elb-superhub-web-dev.vip_port_id
}

resource "huaweicloud_lb_listener" "listener-superhub-web-dev-80" {
  name            = "listener-superhub-web-dev-80"
  protocol        = "HTTP"
  protocol_port   = 80
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-web-dev.id
}
resource "huaweicloud_lb_listener" "listener-superhub-web-dev-443" {
  name            = "listener-superhub-web-dev-443"
  protocol        = "HTTP"
  protocol_port   = 443
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-web-dev.id
}

resource "huaweicloud_lb_listener" "listener-superhub-web-dev-54001" {
  name            = "listener-superhub-web-dev-54001"
  protocol        = "TCP"
  protocol_port   = 54001
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-web-dev.id
}

resource "huaweicloud_lb_pool" "pool-superhub-web-dev-80" {
  name        = "pool-superhub-web-dev-80"
  protocol    = "HTTP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-web-dev-80.id
}

resource "huaweicloud_lb_pool" "pool-superhub-web-dev-54001" {
  name        = "pool-superhub-web-dev-54001"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-web-dev-54001.id
}

resource "huaweicloud_lb_pool" "pool-superhub-web-dev-443" {
  name        = "pool-superhub-web-dev-443"
  protocol    = "HTTP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-web-dev-443.id
}

resource "huaweicloud_lb_monitor" "health-superhub-web-dev-80" {
  name           = "health_check"
  type           = "HTTP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-web-dev-80.id
}

resource "huaweicloud_lb_monitor" "health-superhub-web-dev-443" {
  name           = "health_check"
  type           = "HTTP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-web-dev-443.id
}
resource "huaweicloud_lb_monitor" "health-superhub-web-dev-54001" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-web-dev-54001.id
}

resource "huaweicloud_lb_member" "member-superhub-web-dev-80" {
  for_each = { for ip in local.ecs_web_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 80
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-web-dev-80.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-web.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-superhub-web-dev-443" {
  for_each = { for ip in local.ecs_web_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 443
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-web-dev-443.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-web.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-superhub-web-dev-54001" {
  for_each = { for ip in local.ecs_web_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 54001
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-web-dev-54001.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-web.ipv4_subnet_id
}





// ELB-SuperHUB-IM-Dev
resource "huaweicloud_lb_loadbalancer" "elb-superhub-im-dev" {
  name          = "elb-superhub-im-dev"
  vip_subnet_id = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-voip.ipv4_subnet_id
}

resource "huaweicloud_vpc_eip_associate" "elb-eipassociate-im-dev" {
  public_ip = data.terraform_remote_state.eip.outputs.eip_info["eip_elb_im"].address
  port_id   = huaweicloud_lb_loadbalancer.elb-superhub-im-dev.vip_port_id
}

resource "huaweicloud_lb_listener" "listener-superhub-im-dev-80" {
  name            = "listener-superhub-im-dev-80"
  protocol        = "HTTP"
  protocol_port   = 80
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-im-dev.id
}
resource "huaweicloud_lb_listener" "listener-superhub-im-dev-443" {
  name            = "listener-superhub-im-dev-443"
  protocol        = "HTTP"
  protocol_port   = 443
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-im-dev.id
}

resource "huaweicloud_lb_listener" "listener-superhub-im-dev-8082" {
  name            = "listener-superhub-im-dev-8082"
  protocol        = "TCP"
  protocol_port   = 8082
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-superhub-im-dev.id
}

resource "huaweicloud_lb_pool" "pool-superhub-im-dev-80" {
  name        = "pool-superhub-im-dev-80"
  protocol    = "HTTP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-im-dev-80.id
}

resource "huaweicloud_lb_pool" "pool-superhub-im-dev-443" {
  name        = "pool-superhub-im-dev-443"
  protocol    = "HTTP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-im-dev-443.id
}

resource "huaweicloud_lb_pool" "pool-superhub-im-dev-8082" {
  name        = "pool-superhub-im-dev-8082"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-superhub-im-dev-8082.id
}



resource "huaweicloud_lb_monitor" "health-superhub-im-dev-80" {
  name           = "health_check"
  type           = "HTTP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-im-dev-80.id
}

resource "huaweicloud_lb_monitor" "health-superhub-im-dev-443" {
  name           = "health_check"
  type           = "HTTP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-im-dev-443.id
}
resource "huaweicloud_lb_monitor" "health-superhub-im-dev-8082" {
  name           = "health_check"
  type           = "HTTP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-superhub-im-dev-8082.id
}


resource "huaweicloud_lb_member" "member-superhub-im-dev-80" {
  for_each = { for ip in local.ecs_voip_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 80
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-im-dev-80.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-voip.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-superhub-im-dev-443" {
  for_each = { for ip in local.ecs_voip_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 443
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-im-dev-443.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-voip.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-superhub-im-dev-8082" {
  for_each = { for ip in local.ecs_voip_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 8082
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-superhub-im-dev-8082.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-ecs-voip.ipv4_subnet_id
}



// ELB-SuperHUB-myapp-Dev
resource "huaweicloud_lb_loadbalancer" "elb-myapp-dev" {
  name          = "elb-myapp-dev"
  vip_subnet_id = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}

/* resource "huaweicloud_vpc_eip_associate" "elb-eipassociate-myapp-dev" {
  public_ip = data.terraform_remote_state.eip.outputs.eip_info["eip_elb_myapp"].address
  port_id   = huaweicloud_lb_loadbalancer.elb-myapp-dev.vip_port_id
} */


resource "huaweicloud_lb_listener" "listener-myapp-dev-6808" {
  name            = "listener-myapp-dev-6808"
  protocol        = "TCP"
  protocol_port   = 6808
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8280" {
  name            = "listener-myapp-dev-8280"
  protocol        = "TCP"
  protocol_port   = 8280
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8488" {
  name            = "listener-myapp-dev-8488"
  protocol        = "TCP"
  protocol_port   = 8488
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8489" {
  name            = "listener-myapp-dev-8489"
  protocol        = "TCP"
  protocol_port   = 8489
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8588" {
  name            = "listener-myapp-dev-8588"
  protocol        = "TCP"
  protocol_port   = 8588
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8688" {
  name            = "listener-myapp-dev-8688"
  protocol        = "TCP"
  protocol_port   = 8688
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8787" {
  name            = "listener-myapp-dev-8787"
  protocol        = "TCP"
  protocol_port   = 8787
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8848" {
  name            = "listener-myapp-dev-8848"
  protocol        = "TCP"
  protocol_port   = 8848
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8911" {
  name            = "listener-myapp-dev-8911"
  protocol        = "TCP"
  protocol_port   = 8911
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-8912" {
  name            = "listener-myapp-dev-8912"
  protocol        = "TCP"
  protocol_port   = 8912
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-9011" {
  name            = "listener-myapp-dev-9011"
  protocol        = "TCP"
  protocol_port   = 9011
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-9082" {
  name            = "listener-myapp-dev-9082"
  protocol        = "TCP"
  protocol_port   = 9082
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-9083" {
  name            = "listener-myapp-dev-9083"
  protocol        = "TCP"
  protocol_port   = 9083
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-9848" {
  name            = "listener-myapp-dev-9848"
  protocol        = "TCP"
  protocol_port   = 9848
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}
resource "huaweicloud_lb_listener" "listener-myapp-dev-20881" {
  name            = "listener-myapp-dev-20881"
  protocol        = "TCP"
  protocol_port   = 20881
  loadbalancer_id = huaweicloud_lb_loadbalancer.elb-myapp-dev.id
}





resource "huaweicloud_lb_pool" "pool-myapp-dev-6808" {
  name        = "pool-myapp-dev-6808"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-6808.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8280" {
  name        = "pool-myapp-dev-8280"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8280.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8488" {
  name        = "pool-myapp-dev-8488"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8488.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8489" {
  name        = "pool-myapp-dev-8489"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8489.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8588" {
  name        = "pool-myapp-dev-8588"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8588.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8688" {
  name        = "pool-myapp-dev-8688"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8688.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8787" {
  name        = "pool-myapp-dev-8787"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8787.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8848" {
  name        = "pool-myapp-dev-8848"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8848.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8911" {
  name        = "pool-myapp-dev-8911"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8911.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-8912" {
  name        = "pool-myapp-dev-8912"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-8912.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-9011" {
  name        = "pool-myapp-dev-9011"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-9011.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-9082" {
  name        = "pool-myapp-dev-9082"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-9082.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-9083" {
  name        = "pool-myapp-dev-9083"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-9083.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-9848" {
  name        = "pool-myapp-dev-9848"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-9848.id
}
resource "huaweicloud_lb_pool" "pool-myapp-dev-20881" {
  name        = "pool-myapp-dev-20881"
  protocol    = "TCP"
  lb_method   = "ROUND_ROBIN"
  listener_id = huaweicloud_lb_listener.listener-myapp-dev-20881.id
}


resource "huaweicloud_lb_member" "member-myapp-dev-6808" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31012
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-6808.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8280" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31008
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8280.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8488" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31001
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8488.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8489" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31006
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8489.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8588" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31002
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8588.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8688" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31005
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8688.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8787" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31011
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8787.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8848" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31014
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8848.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8911" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31004
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8911.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-8912" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31007
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-8912.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-9011" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31009
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-9011.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-9082" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31010
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-9082.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-9083" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31013
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-9083.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-9848" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 31015
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-9848.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}
resource "huaweicloud_lb_member" "member-myapp-dev-20881" {
  for_each = { for ip in local.ecs_myapp_ips : ip => local.elb_member_map[ip] }

  address       = each.key
  protocol_port = 20881
  weight        = 1
  pool_id       = huaweicloud_lb_pool.pool-myapp-dev-20881.id
  subnet_id     = data.terraform_remote_state.subnet.outputs.subnet_info.subnet-me212-dev-baidu_hub-cce-myapp.ipv4_subnet_id
}



resource "huaweicloud_lb_monitor" "health-myapp-dev-6808" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-6808.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8280" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8280.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8488" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8488.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8489" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8489.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8588" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8588.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8688" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8688.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8787" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8787.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8848" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8848.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8911" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8911.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-8912" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-8912.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-9011" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-9011.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-9082" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-9082.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-9083" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-9083.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-9848" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-9848.id
}
resource "huaweicloud_lb_monitor" "health-myapp-dev-20881" {
  name           = "health_check"
  type           = "TCP"
  url_path       = "/"
  expected_codes = "200-202"
  delay          = 10
  timeout        = 5
  max_retries    = 3
  pool_id        = huaweicloud_lb_pool.pool-myapp-dev-20881.id
}